package com.icts.shortfilmfestival.push;

import oot.activity.ProfileActivity;
import oot.data.Connection;
import oot.data.JSonPaser;
import oot.data.User;
import oot.tab.activity.R;
import oot.tab.activity.Utils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.androidquery.AQuery;

@SuppressLint("ParserError")
public class MessageReceivedActivity extends Activity {
	public static int numberMessage = 0;
	private TextView header;
	private AQuery aQuery;
	private LinearLayout item;
	private User follow;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.message_result);
		aQuery = new AQuery(MessageReceivedActivity.this);
		item = (LinearLayout) findViewById(R.id.user_item);
		header = (TextView) findViewById(R.id.tv_head_not);
		header.setText(Utils.notiType);
		Log.e("MES",Utils.notiMsg);
		try {
			JSONArray jsonArray = new JSONArray(Utils.notiMsg);
			JSONObject user1 = jsonArray.getJSONObject(0);
			follow = JSonPaser.paserUser(user1);
			JSONObject user2 = jsonArray.getJSONObject(1);
			User followed = JSonPaser.paserUser(user2);
			TextView view = (TextView) findViewById(R.id.result_message);
			aQuery.id(R.id.mes_avatar).visible().image(Connection.BASE_URL_IMAGE+follow.getUserAvatarURL(),true,true,0,R.drawable.btnava);
			view.setText(follow.getUserScreenName() +" has started follow you");
			item.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(getApplicationContext(),ProfileActivity.class);
					intent.putExtra("user", follow);
					startActivity(intent);
				}
			});
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
